SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[paAgregarValorCampoDeDocumento]

@Documento INT,
@CampoDeFormulario INT,
@Valor VARCHAR(255),
@EsNulo VARCHAR(1)

AS
SET NOCOUNT ON
DECLARE @Error INT
SET @Error = 0

BEGIN TRANSACTION

-- Inserto el registro de valor del campo del formulario
INSERT INTO tb_ValoresCampoDeDocumento (Documento, CampoDeFormulario, Valor, EsNulo)
	VALUES(@Documento, @CampoDeFormulario, @Valor, @EsNulo)

SELECT @Error = @@ERROR

IF @Error <> 0 GOTO Salir

Salir:

IF @Error = 0
	COMMIT TRANSACTION
ELSE
	ROLLBACK TRANSACTION
GO
GRANT EXECUTE ON  [dbo].[paAgregarValorCampoDeDocumento] TO [GestionDeDocumentos]
GO
